import Vue from 'vue'
import Vuex, { createLogger } from 'vuex'
import { config } from 'vuex-module-decorators'

import { vuexApp, vuexLocal } from './plugins'
import { setupStoreSubscribe } from './subscribe'

config.rawError = true

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'
const plugins = [vuexLocal.plugin, vuexApp.plugin]
if (debug) plugins.push(createLogger())

const store = new Vuex.Store({
  strict: debug,
  plugins: plugins
})

setupStoreSubscribe(store)

export default store
